package com.itheima.util;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Random;

/*
专门用来负责生成各种随机

 */
public class RandomUitl {
    private static Random r = new Random();

    //随机生成姓
    public static String randomXing() {
        int i = r.nextInt(20);
        if (i == 0) {
            ArrayList<String> list1 = NameUtil.fuXing();
            return list1.get(r.nextInt(list1.size()));
        }
        ArrayList<String> list = NameUtil.danXing();
        return list.get(r.nextInt(list.size()));
    }


    //随机生成名
    public static String randomMing() {
        ArrayList<String> zi = NameUtil.getZi();

        int i = r.nextInt(2);
        if (i == 0) {
            int index = r.nextInt(zi.size());
            return zi.get(index);
        }else {
            int index1 = r.nextInt(zi.size());
            int index2 = r.nextInt(zi.size());
            return zi.get(index1)+zi.get(index2);
        }


    }

    //生成性别
    public static String randomGender() {
        int i = r.nextInt(2);
        if (i == 0) {
            return "男";
        }
        return "女";

    }
//    生成生日

    public static LocalDate randomBirthday() {
        int year = r.nextInt(10) + 1995;
        int month = r.nextInt(12) + 1;
        int day = r.nextInt(28) + 1;
        return LocalDate.of(year, month, day);

    }

    //生成每个人的微信号
    public static ArrayList<String> randomWXNumber() {
        ArrayList<String> list = new ArrayList<>();
        int i = r.nextInt(2);
        if (i == 0) {
            //
            String sb = getWXNumber();
            list.add(sb.toString());
        } else {
            String sb = getWXNumber();
            list.add(sb.toString());
            String sb2 = getWXNumber();
            list.add(sb2.toString());
        }
        return list;

    }

    //生成单个微信号
    private static String getWXNumber() {
        int count = r.nextInt(20);
        StringBuilder sb = new StringBuilder();
        for (int j = 0; j < count; j++) {
            sb.append(randomChar());
        }
        return sb.toString();
    }

    //获取一个随机的字符
    public static char randomChar() {
        StringBuilder sb = new StringBuilder();
        for (int i = 'A'; i <= 'Z'; i++) {
            sb.append((char) i);
        }
        for (int i = 'a'; i <= 'z'; i++) {
            sb.append((char) i);
        }
        for (int i = '0'; i <= '9'; i++) {
            sb.append((char) i);
        }
        int i = r.nextInt(sb.length());
        return sb.toString().charAt(i);
    }

    //生成手机号
    public static String randomPhone() {

        StringBuilder sb = new StringBuilder("1");
        int i = r.nextInt(6) + 3;
        sb.append(i);
        for (int j = 0; j < 9; j++) {
            sb.append(r.nextInt(10));

        }

        return sb.toString();
    }

}
